package org.hdl.anima.message;

import java.io.IOException;

import org.hdl.anima.common.io.InputArchive;
import org.hdl.anima.common.io.OutputArchive;
import org.hdl.anima.common.io.Record;

import com.google.common.base.Preconditions;

/**
 * 
 * @author qiuhd
 * @since  2014年8月15日
 */
public class RequestWrap implements Record {

	private int sId;   		//发送人身份id
	private IMessage msg;
	
	public RequestWrap(IMessage request) {
		Preconditions.checkArgument(request != null, "request is null!");
		this.msg = request;
	}
	
	@Override
	public void serialize(OutputArchive archive) throws IOException {
		archive.writeRecord(msg);
		archive.writeInt(sId);
	}

	@Override
	public void deserialize(InputArchive archive) throws IOException {
		archive.readRecord(msg);
		this.sId = archive.readInt();
	}

	public int getsId() {
		return sId;
	}

	public void setsId(int sId) {
		this.sId = sId;
	}

	public IMessage getMessage() {
		return msg;
	}

	public void setRequest(IMessage msg) {
		this.msg = msg;
	}
}

